package com.library.controller;

import com.library.commen.utils.AliOSSUtils;
import com.library.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@Slf4j
public class UploadController {
    @Autowired
    private AliOSSUtils aliOSSUtils;

    @PostMapping("/upload")
    public Result upload(MultipartFile image) throws IOException {
        log.info("文件开始传输{}",image);
        String upload = aliOSSUtils.upload(image);
        log.info("文件传输完成[]",upload);
        return Result.success(upload);
    }
}
